<?  layout("../layout/default.html") { ?>
<div class="admin-panel">
	<div class="tab">
		<div class="tab-head">
			<strong> <? if(@data.isNew()){ ?>添加<?}else{?>编辑<?}?>用户
			</strong> <span class="tab-more"><a href="javascript:history.go(-1)"
				class="button  button-little bg-blue  icon-step-backward"> 返回</a></span>
			<ul class="tab-nav">
				<li class="active"><a href="#tab-set">用户信息</a></li>
				<li><a href="#tab-role">角色配置</a></li>
				<!-- <li><a href="#tab-other">辅助信息</a></li> -->
			</ul>
		</div>
		<div class="tab-body">
			<script type="text/javascript">
		function islong(){			 
		    var str = document.getElementById("user_account").value.trim();
		    var str1 = document.getElementById("user_password").value.trim();
		    var str2 = document.getElementById("user_cname").value.trim();
		    var str3 = document.getElementById("user_ename").value.trim();
		    var reg=/[^\u4E00-\u9FA5]/;
		    if(str.length>20){    
		        alert("对不起，用户名输入过长!");
		        document.getElementById("user_account").value="";
		        return false; 
		    } 
		    if(str1.length>32){    
		        alert("对不起，密码设置过长!");
		        document.getElementById("user_password").value="";
		        return false; 
		    } 
		    if(str2.match(reg)){    
		        alert("对不起，请输入中文名!");
		        document.getElementById("user_cname").value="";
		        return false; 
		    }
		    if(str2.length>10){    
		        alert("对不起，中文名输入过长!");
		        document.getElementById("user_cname").value="";
		        return false; 
		    }
		    
		    if(str3.length>50){    
		        alert("对不起，英文名输入过长!");
		        document.getElementById("user_ename").value="";
		        return false; 
		    }

		}

		</script>


			<form method="post" class="form-x" action="">

				<div class="tab-panel active" id="tab-set">
					<div class="form-group">
						<div class="label">
							<label for="sitename">用户名</label>
						</div>
						<div class="field">
							<input type="text" class="input" id="user_account"
								name="user.account" size="20" placeholder="请填写用户名"
								data-validate="required:请填写用户名" value="${data.account!" "}" />
						</div>
					</div>

					<div class="form-group">
						<div class="label">
							<label for="sitename">密码</label>
						</div>
						<div class="field">
							<input type="text" class="input" id="user_password"
								name="user.password" size="32" placeholder="请填写密码""}"/>
							<? if(@data.isNew()){ ?> data-validate="required:请填写密码"
							<? } ?>
							<? if(!@data.isNew()){ ?>
							<div class="input-note">请留空表示无需更改</div>
							<? } ?>
						</div>
					</div>

					<div class="form-group">
						<div class="label">
							<label for="sitename">中文名</label>
						</div>
						<div class="field">
							<input type="text" class="input" id="user_cname"
								name="user.cname" size="10" placeholder="请填写中文名"
								data-validate="" value="${data.cname!" "}"/>
						</div>
					</div>

					<div class="form-group">
						<div class="label">
							<label for="sitename">英文名</label>
						</div>
						<div class="field">
							<input type="text" class="input" id="user_ename"
								name="user.ename" size="50" placeholder="请填写英文名"
								data-validate="" value="${data.ename!" "}"/>
						</div>
					</div>

					<div class="form-group">
						<div class="label">
							<label for="sitename">所在部门</label>
						</div>
						<div class="field">
							<select class="input" name="user.dept_id" id="user_dept_id">
								<? for(dept in depts){ ?>
								<option value="${dept.key}">${dept.value }</option>
								<? } ?>
							</select>
						</div>
					</div>
					<script type="text/javascript">$("#user_dept_id").val(${data.dept_id});</script>
					<div class="form-group">
						<div class="label">
							<label for="sitename">是否启用</label>
						</div>
						<div class="field">
							<div class="button-group button-group-small radio">
								<label class="button" id="user_flg_true"><input
									name="user.flg" value="1" type="radio"><span
									class="icon icon-check"></span> 是</label> <label class="button"
									id="user_flg_false"><input name="user.flg" value="0"
									type="radio"><span class="icon icon-times"></span> 否</label>
							</div>
							<script>
							$("#user_flg_${data.flg!true}").addClass('active').children('input').attr('checked',true);
						</script>
						</div>
					</div>

					<div class="form-group">
						<div class="label">
							<label for="sitename">备注</label>
						</div>
						<div class="field">
							<input type="text" class="input" id="user_remark"
								name="user.remark" size="1000" placeholder="请填写备注"
								data-validate="" value="${data.remark!" "}"/>
						</div>
					</div>



					<div class="form-button">
						<button class="button bg-main" type="submit"
							onclick="return islong()">提交</button>
					</div>
				</div>
				<div class="tab-panel" id="tab-role">
					<div class="form-group">
						<div class="label">
							<label for="sitename">选择角色</label>
						</div>
						<div class="field">
							<? for(role in allroles){ ?>
							<div class="button-group checkbox">
								<label class="button" id="role_${role.id}"> <input
									name="roles" value="${role.id}" type="checkbox"> <span
									class="icon icon-check"></span> ${role.cname}
								</label>
							</div>
							<? } ?>

						</div>
					</div>
					<div class="form-button">
						<button class="button bg-main" type="submit">提交</button>
					</div>
					<script type="text/javascript">
					<? for(role in useroles!){ ?>
					$("#role_${role.role_id}").addClass("active").children("input").attr("checked",true);
					<? }?>
				</script>
				</div>
			</form>
			<div class="tab-panel" id="tab-other">
				<form class="form-x">
					<div class="form-group">
						<div class="label">
							<label for="sitename">登录次数</label>
						</div>
						<div class="field">
							<input type="text" class="input" id="user_login_count"
								name="user.login_count" size="11" placeholder="登录次数"
								data-validate="required:请填写登录次数" value="${data.login_count!" 0"}"/>
						</div>
					</div>

					<div class="form-group">
						<div class="label">
							<label for="sitename">最后登录时间</label>
						</div>
						<div class="field">
							<input type="text" class="input" id="user_last_login_time"
								name="user.last_login_time" size="11" placeholder="最后登录时间"
								data-validate="" value="${data.last_login_time!" "}"/>
						</div>
					</div>

					<div class="form-group">
						<div class="label">
							<label for="sitename">创建时间</label>
						</div>
						<div class="field">
							<input type="text" class="input" id="user_create_time"
								name="user.create_time" size="11" placeholder="创建时间"
								data-validate="required:请填写创建时间" value="${data.create_time!" "}"/>
						</div>
					</div>

					<div class="form-group">
						<div class="label">
							<label for="sitename">创建者</label>
						</div>
						<div class="field">
							<input type="text" class="input" id="user_create_user_id"
								name="user.create_user_id" size="11" placeholder="创建者"
								data-validate="required:请填写创建者" value="${data.create_user_id!" "}"/>
						</div>
					</div>

					<div class="form-group">
						<div class="label">
							<label for="sitename">更新时间</label>
						</div>
						<div class="field">
							<input type="text" class="input" id="user_update_time"
								name="user.update_time" size="11" placeholder="更新时间"
								data-validate="" value="${data.update_time!" "}"/>
						</div>
					</div>

					<div class="form-group">
						<div class="label">
							<label for="sitename">更新者</label>
						</div>
						<div class="field">
							<input type="text" class="input" id="user_update_user_id"
								name="user.update_user_id" size="11" placeholder="更新者"
								data-validate="" value="${data.update_user_id!" "}"/>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
<?  } ?>